// Internal action code for project traffic_control_jason

package my;

import jason.asSemantics.*;
import jason.asSyntax.*;

@SuppressWarnings("serial")
public class next_pos extends DefaultInternalAction {

	@Override
    public Object execute(TransitionSystem ts, Unifier un, Term[] terms) throws Exception {
        int intX = (int) ((NumberTerm) terms[2]).solve();
        int intY = (int) ((NumberTerm) terms[3]).solve();
        String direction = terms[4].toString();
    	
        if(direction.equals("up")){
        	intY--;
        }else if(direction.equals("down")){
        	intY++;
        }else if(direction.equals("right")){
        	intX++;
        }else if(direction.equals("left")){
        	intX--;
        }
        return un.unifies(terms[0], new NumberTermImpl(intX)) & un.unifies(terms[1], new NumberTermImpl(intY));
    }
}
